/* 
 * Combination Sum
 */

#include "../func.h"

void dfs(vector<int> &nums, vector<int> &path, vector<vector<int>> &result, int gap, int start)
{
    if (0 == gap) {
        result.push_back(path);
        return;
    }
    for (size_t i = start; i < nums.size(); ++i) {
        if (gap < nums[i])
            return;

        path.push_back(nums[i]);
        dfs(nums, path, result, gap - nums[i], i);
        path.pop_back();
    }
}